package com.simCardTool.service;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.provider.Settings;
import android.util.Log;

import com.simCardTool.ui.SimCardToolDialogActivity;

public class SimCardToolService extends Service {
    
	/** tag */
	private final static String TAG = "SimCardToolService"; 
	
	@Override
	public void onStart(Intent intent, int flags) {
		Log.i(TAG, "SimCardToolService onStartCommand start");
		
		//set the fly mode
        setAirplaneMode();
        
        //show the dialog to warn user shout down the device
        Intent dialogIntent = new Intent(this, SimCardToolDialogActivity.class);
        this.startActivity(dialogIntent);
	}
    
    /**
     * set the airplane mode
     */
    private void setAirplaneMode() {
    	Settings.System.putInt(getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 1);
        Intent localIntent = new Intent("android.intent.action.AIRPLANE_MODE").putExtra("state", true);
        sendBroadcast(localIntent);
    }
    
	@Override
	public IBinder onBind(Intent arg0) {
		return null;
	}

	  

}